package com.dimples.dd.system.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dimples.dd.system.model.entity.SystemFileContentDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface SystemFileContentMapper extends com.dimples.dd.mybatis.core.mapper.BaseMapperX<SystemFileContentDO> {

    /**
     * 根据configId和path删除
     *
     * @param configId 配置id
     * @param path     文件路径
     */
    default void deleteByConfigIdAndPath(Long configId, String path) {
        this.delete(new LambdaQueryWrapper<SystemFileContentDO>()
                .eq(SystemFileContentDO::getConfigId, configId)
                .eq(SystemFileContentDO::getPath, path));
    }

    /**
     * 根据configId和path查询
     *
     * @param configId 配置id
     * @param path     文件路径
     * @return 文件内容
     */
    default List<SystemFileContentDO> selectListByConfigIdAndPath(Long configId, String path) {
        return selectList(new LambdaQueryWrapper<SystemFileContentDO>()
                .eq(SystemFileContentDO::getConfigId, configId)
                .eq(SystemFileContentDO::getPath, path));
    }
}